package com.pk.android.model;

import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.pk.android.R;
import com.pk.android.view.adapter.NavDrawerAdapter.LayoutSectionType;

public class NavDrawerItem  implements NavDrawer{
	private int mIcon;
	private int mId;
	private String mText;
	private String mSubText;
	private boolean updateActionBarTitle ;
	
	public int getIcon() {
		return mIcon;
	}
	public void setIcon(int icon) {
		mIcon = icon;
	}
	@Override
	public String getText() {
		return mText;
	}
	public void setText(String text) {
		mText = text;
	}
	public String getSubText() {
		return mSubText;
	}
	public void setSubText(String subText) {
		mSubText = subText;
	}
	@Override
	public int getId() {
		return mId;
	}
	public void setId(int id) {
		mId = id;
	}
	
	
	public NavDrawerItem(int id, String text, String subText, int imageResId, boolean updateActionBarTitle)
	{
		this.setId(id);
		this.setText(text);
		this.setSubText(subText);
		this.setIcon(imageResId);
		this.setUpdateActionBarTitle(updateActionBarTitle);
        
	}
	
	public static NavDrawerItem create( int id, String text, String subText, int imageResId, boolean updateActionBarTitle) {
        return new NavDrawerItem(id, text, subText, imageResId, updateActionBarTitle);
    }
	public static NavDrawerItem create( int id, String text, boolean updateActionBarTitle) {
        return new NavDrawerItem(id, text, "", 0, updateActionBarTitle);
    }
	
	@Override
	public int getViewType() {
		return LayoutSectionType.LIST_ITEM.ordinal();
	}
	
	@Override
	public View getView(LayoutInflater inflater, View convertView) {
		
		View rowView;
		if (convertView == null) {
			 rowView = inflater.inflate(R.layout.listview_navdrawer_item, null);
		} else {
			//rowView = convertView;
			rowView = inflater.inflate(R.layout.listview_navdrawer_item, null);
		}
		
		TextView textViewItem = (TextView) rowView.findViewById(R.id.txt_item);
		TextView textViewSubItem = (TextView) rowView.findViewById(R.id.txt_subItem);
	    ImageView imageViewItem = (ImageView) rowView.findViewById(R.id.icon);


	    textViewItem.setText(this.getText());
	    textViewSubItem.setText(this.getSubText());
	    
	    imageViewItem.setImageResource(getIcon());
	    
	    return rowView;
	}
	
	@Override
	public boolean isEnabled(int position) {
		// TODO Auto-generated method stub
		return true;
	}

	@Override
    public boolean updateActionBarTitle() {
		// TODO Auto-generated method stub
        return false;
    }

	public boolean getUpdateActionBarTitle()
	{
		return this.updateActionBarTitle;
	}
	
    public void setUpdateActionBarTitle(boolean updateActionBarTitle) {
        this.updateActionBarTitle = updateActionBarTitle;
    }
}
